package com.howard.tools.email;

import javax.mail.internet.MimeMessage;

import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;

public class EmailHelper {
	private JavaMailSender javaMailSender;

	private String systemEmail;

	public void sendMail(String to, String subject, String htmlText)
			throws Exception {
		MimeMessage msg = javaMailSender.createMimeMessage();
		MimeMessageHelper msgHelper = new MimeMessageHelper(msg);

		msgHelper.setFrom(systemEmail);
		msgHelper.setTo(to);
		msgHelper.setSubject(subject);
		msgHelper.setText(htmlText, true);

		javaMailSender.send(msg);
	}

	public JavaMailSender getJavaMailSender() {
		return javaMailSender;
	}

	public void setJavaMailSender(JavaMailSender javaMailSender) {
		this.javaMailSender = javaMailSender;
	}

	public String getSystemEmail() {
		return systemEmail;
	}

	public void setSystemEmail(String systemEmail) {
		this.systemEmail = systemEmail;
	}
}
